<?php
if (session_id() == "") session_start(); // Initialize Session data
ob_start(); // Turn on output buffering
?>
<?php include_once "ewcfg10.php" ?>
<?php include_once "ewmysql10.php" ?>
<?php include_once "phpfn10.php" ?>
<?php include_once "pedidosinfo.php" ?>
<?php include_once "usuariosinfo.php" ?>
<?php include_once "pedidodetallegridcls.php" ?>
<?php include_once "pedidohistorialgridcls.php" ?>
<?php include_once "userfn10.php" ?>
<?php

//
// Page class
//

$pedidos_edit = NULL; // Initialize page object first

class cpedidos_edit extends cpedidos {

	// Page ID
	var $PageID = 'edit';

	// Project ID
	var $ProjectID = "{F232ADC5-E4A2-4026-8F03-D0514C19EE8E}";

	// Table name
	var $TableName = 'pedidos';

	// Page object name
	var $PageObjName = 'pedidos_edit';

	// Page name
	function PageName() {
		return ew_CurrentPage();
	}

	// Page URL
	function PageUrl() {
		$PageUrl = ew_CurrentPage() . "?";
		if ($this->UseTokenInUrl) $PageUrl .= "t=" . $this->TableVar . "&"; // Add page token
		return $PageUrl;
	}

	// Message
	function getMessage() {
		return @$_SESSION[EW_SESSION_MESSAGE];
	}

	function setMessage($v) {
		ew_AddMessage($_SESSION[EW_SESSION_MESSAGE], $v);
	}

	function getFailureMessage() {
		return @$_SESSION[EW_SESSION_FAILURE_MESSAGE];
	}

	function setFailureMessage($v) {
		ew_AddMessage($_SESSION[EW_SESSION_FAILURE_MESSAGE], $v);
	}

	function getSuccessMessage() {
		return @$_SESSION[EW_SESSION_SUCCESS_MESSAGE];
	}

	function setSuccessMessage($v) {
		ew_AddMessage($_SESSION[EW_SESSION_SUCCESS_MESSAGE], $v);
	}

	function getWarningMessage() {
		return @$_SESSION[EW_SESSION_WARNING_MESSAGE];
	}

	function setWarningMessage($v) {
		ew_AddMessage($_SESSION[EW_SESSION_WARNING_MESSAGE], $v);
	}

	// Show message
	function ShowMessage() {
		$hidden = FALSE;
		$html = "";

		// Message
		$sMessage = $this->getMessage();
		$this->Message_Showing($sMessage, "");
		if ($sMessage <> "") { // Message in Session, display
			if (!$hidden)
				$sMessage = "<button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button>" . $sMessage;
			$html .= "<div class=\"alert alert-success ewSuccess\">" . $sMessage . "</div>";
			$_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message in Session
		}

		// Warning message
		$sWarningMessage = $this->getWarningMessage();
		$this->Message_Showing($sWarningMessage, "warning");
		if ($sWarningMessage <> "") { // Message in Session, display
			if (!$hidden)
				$sWarningMessage = "<button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button>" . $sWarningMessage;
			$html .= "<div class=\"alert alert-warning ewWarning\">" . $sWarningMessage . "</div>";
			$_SESSION[EW_SESSION_WARNING_MESSAGE] = ""; // Clear message in Session
		}

		// Success message
		$sSuccessMessage = $this->getSuccessMessage();
		$this->Message_Showing($sSuccessMessage, "success");
		if ($sSuccessMessage <> "") { // Message in Session, display
			if (!$hidden)
				$sSuccessMessage = "<button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button>" . $sSuccessMessage;
			$html .= "<div class=\"alert alert-success ewSuccess\">" . $sSuccessMessage . "</div>";
			$_SESSION[EW_SESSION_SUCCESS_MESSAGE] = ""; // Clear message in Session
		}

		// Failure message
		$sErrorMessage = $this->getFailureMessage();
		$this->Message_Showing($sErrorMessage, "failure");
		if ($sErrorMessage <> "") { // Message in Session, display
			if (!$hidden)
				$sErrorMessage = "<button type=\"button\" class=\"close\" data-dismiss=\"alert\">&times;</button>" . $sErrorMessage;
			$html .= "<div class=\"alert alert-error ewError\">" . $sErrorMessage . "</div>";
			$_SESSION[EW_SESSION_FAILURE_MESSAGE] = ""; // Clear message in Session
		}
		echo "<table class=\"ewStdTable\"><tr><td><div class=\"ewMessageDialog\"" . (($hidden) ? " style=\"display: none;\"" : "") . ">" . $html . "</div></td></tr></table>";
	}
	var $PageHeader;
	var $PageFooter;

	// Show Page Header
	function ShowPageHeader() {
		$sHeader = $this->PageHeader;
		$this->Page_DataRendering($sHeader);
		if ($sHeader <> "") { // Header exists, display
			echo "<p>" . $sHeader . "</p>";
		}
	}

	// Show Page Footer
	function ShowPageFooter() {
		$sFooter = $this->PageFooter;
		$this->Page_DataRendered($sFooter);
		if ($sFooter <> "") { // Footer exists, display
			echo "<p>" . $sFooter . "</p>";
		}
	}

	// Validate page request
	function IsPageRequest() {
		global $objForm;
		if ($this->UseTokenInUrl) {
			if ($objForm)
				return ($this->TableVar == $objForm->GetValue("t"));
			if (@$_GET["t"] <> "")
				return ($this->TableVar == $_GET["t"]);
		} else {
			return TRUE;
		}
	}

	//
	// Page class constructor
	//
	function __construct() {
		global $conn, $Language;
		$GLOBALS["Page"] = &$this;

		// Language object
		if (!isset($Language)) $Language = new cLanguage();

		// Parent constuctor
		parent::__construct();

		// Table object (pedidos)
		if (!isset($GLOBALS["pedidos"]) || get_class($GLOBALS["pedidos"]) == "cpedidos") {
			$GLOBALS["pedidos"] = &$this;
			$GLOBALS["Table"] = &$GLOBALS["pedidos"];
		}

		// Table object (usuarios)
		if (!isset($GLOBALS['usuarios'])) $GLOBALS['usuarios'] = new cusuarios();

		// Page ID
		if (!defined("EW_PAGE_ID"))
			define("EW_PAGE_ID", 'edit', TRUE);

		// Table name (for backward compatibility)
		if (!defined("EW_TABLE_NAME"))
			define("EW_TABLE_NAME", 'pedidos', TRUE);

		// Start timer
		if (!isset($GLOBALS["gTimer"])) $GLOBALS["gTimer"] = new cTimer();

		// Open connection
		if (!isset($conn)) $conn = ew_Connect();
	}

	// 
	//  Page_Init
	//
	function Page_Init() {
		global $gsExport, $gsExportFile, $UserProfile, $Language, $Security, $objForm;

		// Security
		$Security = new cAdvancedSecurity();
		if (!$Security->IsLoggedIn()) $Security->AutoLogin();
		if (!$Security->IsLoggedIn()) {
			$Security->SaveLastUrl();
			$this->Page_Terminate("login.php");
		}
		$Security->TablePermission_Loading();
		$Security->LoadCurrentUserLevel($this->ProjectID . $this->TableName);
		$Security->TablePermission_Loaded();
		if (!$Security->IsLoggedIn()) {
			$Security->SaveLastUrl();
			$this->Page_Terminate("login.php");
		}
		if (!$Security->CanEdit()) {
			$Security->SaveLastUrl();
			$this->setFailureMessage($Language->Phrase("NoPermission")); // Set no permission
			$this->Page_Terminate("pedidoslist.php");
		}

		// Create form object
		$objForm = new cFormObj();
		$this->CurrentAction = (@$_GET["a"] <> "") ? $_GET["a"] : @$_POST["a_list"]; // Set up curent action
		$this->pedidoID->Visible = !$this->IsAdd() && !$this->IsCopy() && !$this->IsGridAdd();

		// Global Page Loading event (in userfn*.php)
		Page_Loading();

		// Page Load event
		$this->Page_Load();
	}

	//
	// Page_Terminate
	//
	function Page_Terminate($url = "") {
		global $conn;

		// Page Unload event
		$this->Page_Unload();

		// Global Page Unloaded event (in userfn*.php)
		Page_Unloaded();
		$this->Page_Redirecting($url);

		 // Close connection
		$conn->Close();

		// Go to URL if specified
		if ($url <> "") {
			if (!EW_DEBUG_ENABLED && ob_get_length())
				ob_end_clean();
			header("Location: " . $url);
		}
		exit();
	}
	var $DbMasterFilter;
	var $DbDetailFilter;

	// 
	// Page main
	//
	function Page_Main() {
		global $objForm, $Language, $gsFormError;

		// Load key from QueryString
		if (@$_GET["pedidoID"] <> "") {
			$this->pedidoID->setQueryStringValue($_GET["pedidoID"]);
		}

		// Set up Breadcrumb
		$this->SetupBreadcrumb();

		// Process form if post back
		if (@$_POST["a_edit"] <> "") {
			$this->CurrentAction = $_POST["a_edit"]; // Get action code
			$this->LoadFormValues(); // Get form values

			// Set up detail parameters
			$this->SetUpDetailParms();
		} else {
			$this->CurrentAction = "I"; // Default action is display
		}

		// Check if valid key
		if ($this->pedidoID->CurrentValue == "")
			$this->Page_Terminate("pedidoslist.php"); // Invalid key, return to list

		// Validate form if post back
		if (@$_POST["a_edit"] <> "") {
			if (!$this->ValidateForm()) {
				$this->CurrentAction = ""; // Form error, reset action
				$this->setFailureMessage($gsFormError);
				$this->EventCancelled = TRUE; // Event cancelled
				$this->RestoreFormValues();
			}
		}
		switch ($this->CurrentAction) {
			case "I": // Get a record to display
				if (!$this->LoadRow()) { // Load record based on key
					if ($this->getFailureMessage() == "") $this->setFailureMessage($Language->Phrase("NoRecord")); // No record found
					$this->Page_Terminate("pedidoslist.php"); // No matching record, return to list
				}

				// Set up detail parameters
				$this->SetUpDetailParms();
				break;
			Case "U": // Update
				$this->SendEmail = TRUE; // Send email on update success
				if ($this->EditRow()) { // Update record based on key
					if ($this->getSuccessMessage() == "")
						$this->setSuccessMessage($Language->Phrase("UpdateSuccess")); // Update success
					if ($this->getCurrentDetailTable() <> "") // Master/detail edit
						$sReturnUrl = $this->GetDetailUrl();
					else
						$sReturnUrl = $this->getReturnUrl();
					$this->Page_Terminate($sReturnUrl); // Return to caller
				} else {
					$this->EventCancelled = TRUE; // Event cancelled
					$this->RestoreFormValues(); // Restore form values if update failed

					// Set up detail parameters
					$this->SetUpDetailParms();
				}
		}

		// Render the record
		$this->RowType = EW_ROWTYPE_EDIT; // Render as Edit
		$this->ResetAttrs();
		$this->RenderRow();
	}

	// Set up starting record parameters
	function SetUpStartRec() {
		if ($this->DisplayRecs == 0)
			return;
		if ($this->IsPageRequest()) { // Validate request
			if (@$_GET[EW_TABLE_START_REC] <> "") { // Check for "start" parameter
				$this->StartRec = $_GET[EW_TABLE_START_REC];
				$this->setStartRecordNumber($this->StartRec);
			} elseif (@$_GET[EW_TABLE_PAGE_NO] <> "") {
				$PageNo = $_GET[EW_TABLE_PAGE_NO];
				if (is_numeric($PageNo)) {
					$this->StartRec = ($PageNo-1)*$this->DisplayRecs+1;
					if ($this->StartRec <= 0) {
						$this->StartRec = 1;
					} elseif ($this->StartRec >= intval(($this->TotalRecs-1)/$this->DisplayRecs)*$this->DisplayRecs+1) {
						$this->StartRec = intval(($this->TotalRecs-1)/$this->DisplayRecs)*$this->DisplayRecs+1;
					}
					$this->setStartRecordNumber($this->StartRec);
				}
			}
		}
		$this->StartRec = $this->getStartRecordNumber();

		// Check if correct start record counter
		if (!is_numeric($this->StartRec) || $this->StartRec == "") { // Avoid invalid start record counter
			$this->StartRec = 1; // Reset start record counter
			$this->setStartRecordNumber($this->StartRec);
		} elseif (intval($this->StartRec) > intval($this->TotalRecs)) { // Avoid starting record > total records
			$this->StartRec = intval(($this->TotalRecs-1)/$this->DisplayRecs)*$this->DisplayRecs+1; // Point to last page first record
			$this->setStartRecordNumber($this->StartRec);
		} elseif (($this->StartRec-1) % $this->DisplayRecs <> 0) {
			$this->StartRec = intval(($this->StartRec-1)/$this->DisplayRecs)*$this->DisplayRecs+1; // Point to page boundary
			$this->setStartRecordNumber($this->StartRec);
		}
	}

	// Get upload files
	function GetUploadFiles() {
		global $objForm;

		// Get upload data
	}

	// Load form values
	function LoadFormValues() {

		// Load from form
		global $objForm;
		if (!$this->pedidoID->FldIsDetailKey)
			$this->pedidoID->setFormValue($objForm->GetValue("x_pedidoID"));
		if (!$this->pedidoTipo->FldIsDetailKey) {
			$this->pedidoTipo->setFormValue($objForm->GetValue("x_pedidoTipo"));
		}
		if (!$this->pedidoFecha->FldIsDetailKey) {
			$this->pedidoFecha->setFormValue($objForm->GetValue("x_pedidoFecha"));
			$this->pedidoFecha->CurrentValue = ew_UnFormatDateTime($this->pedidoFecha->CurrentValue, 7);
		}
		if (!$this->pedidoAutor->FldIsDetailKey) {
			$this->pedidoAutor->setFormValue($objForm->GetValue("x_pedidoAutor"));
		}
		if (!$this->pedidoSucursal->FldIsDetailKey) {
			$this->pedidoSucursal->setFormValue($objForm->GetValue("x_pedidoSucursal"));
		}
		if (!$this->pedidoOrigen->FldIsDetailKey) {
			$this->pedidoOrigen->setFormValue($objForm->GetValue("x_pedidoOrigen"));
		}
		if (!$this->pedidoDestino->FldIsDetailKey) {
			$this->pedidoDestino->setFormValue($objForm->GetValue("x_pedidoDestino"));
		}
		if (!$this->pedidoEstado->FldIsDetailKey) {
			$this->pedidoEstado->setFormValue($objForm->GetValue("x_pedidoEstado"));
		}
		if (!$this->pedidoObservacion->FldIsDetailKey) {
			$this->pedidoObservacion->setFormValue($objForm->GetValue("x_pedidoObservacion"));
		}
		if (!$this->pedidoUltimaModificacion->FldIsDetailKey) {
			$this->pedidoUltimaModificacion->setFormValue($objForm->GetValue("x_pedidoUltimaModificacion"));
			$this->pedidoUltimaModificacion->CurrentValue = ew_UnFormatDateTime($this->pedidoUltimaModificacion->CurrentValue, 7);
		}
		if (!$this->pedidoUltimaModificacionUsuario->FldIsDetailKey) {
			$this->pedidoUltimaModificacionUsuario->setFormValue($objForm->GetValue("x_pedidoUltimaModificacionUsuario"));
		}
		if (!$this->pedidoActivo->FldIsDetailKey) {
			$this->pedidoActivo->setFormValue($objForm->GetValue("x_pedidoActivo"));
		}
		if (!$this->pedidoTratado->FldIsDetailKey) {
			$this->pedidoTratado->setFormValue($objForm->GetValue("x_pedidoTratado"));
		}
		if (!$this->pedidoFechaPlanificada->FldIsDetailKey) {
			$this->pedidoFechaPlanificada->setFormValue($objForm->GetValue("x_pedidoFechaPlanificada"));
			$this->pedidoFechaPlanificada->CurrentValue = ew_UnFormatDateTime($this->pedidoFechaPlanificada->CurrentValue, 7);
		}
		if (!$this->pedidoMotivo->FldIsDetailKey) {
			$this->pedidoMotivo->setFormValue($objForm->GetValue("x_pedidoMotivo"));
		}
		if (!$this->pedidoAnterior->FldIsDetailKey) {
			$this->pedidoAnterior->setFormValue($objForm->GetValue("x_pedidoAnterior"));
		}
	}

	// Restore form values
	function RestoreFormValues() {
		global $objForm;
		$this->LoadRow();
		$this->pedidoID->CurrentValue = $this->pedidoID->FormValue;
		$this->pedidoTipo->CurrentValue = $this->pedidoTipo->FormValue;
		$this->pedidoFecha->CurrentValue = $this->pedidoFecha->FormValue;
		$this->pedidoFecha->CurrentValue = ew_UnFormatDateTime($this->pedidoFecha->CurrentValue, 7);
		$this->pedidoAutor->CurrentValue = $this->pedidoAutor->FormValue;
		$this->pedidoSucursal->CurrentValue = $this->pedidoSucursal->FormValue;
		$this->pedidoOrigen->CurrentValue = $this->pedidoOrigen->FormValue;
		$this->pedidoDestino->CurrentValue = $this->pedidoDestino->FormValue;
		$this->pedidoEstado->CurrentValue = $this->pedidoEstado->FormValue;
		$this->pedidoObservacion->CurrentValue = $this->pedidoObservacion->FormValue;
		$this->pedidoUltimaModificacion->CurrentValue = $this->pedidoUltimaModificacion->FormValue;
		$this->pedidoUltimaModificacion->CurrentValue = ew_UnFormatDateTime($this->pedidoUltimaModificacion->CurrentValue, 7);
		$this->pedidoUltimaModificacionUsuario->CurrentValue = $this->pedidoUltimaModificacionUsuario->FormValue;
		$this->pedidoActivo->CurrentValue = $this->pedidoActivo->FormValue;
		$this->pedidoTratado->CurrentValue = $this->pedidoTratado->FormValue;
		$this->pedidoFechaPlanificada->CurrentValue = $this->pedidoFechaPlanificada->FormValue;
		$this->pedidoFechaPlanificada->CurrentValue = ew_UnFormatDateTime($this->pedidoFechaPlanificada->CurrentValue, 7);
		$this->pedidoMotivo->CurrentValue = $this->pedidoMotivo->FormValue;
		$this->pedidoAnterior->CurrentValue = $this->pedidoAnterior->FormValue;
	}

	// Load row based on key values
	function LoadRow() {
		global $conn, $Security, $Language;
		$sFilter = $this->KeyFilter();

		// Call Row Selecting event
		$this->Row_Selecting($sFilter);

		// Load SQL based on filter
		$this->CurrentFilter = $sFilter;
		$sSql = $this->SQL();
		$res = FALSE;
		$rs = ew_LoadRecordset($sSql);
		if ($rs && !$rs->EOF) {
			$res = TRUE;
			$this->LoadRowValues($rs); // Load row values
			$rs->Close();
		}
		return $res;
	}

	// Load row values from recordset
	function LoadRowValues(&$rs) {
		global $conn;
		if (!$rs || $rs->EOF) return;

		// Call Row Selected event
		$row = &$rs->fields;
		$this->Row_Selected($row);
		$this->pedidoID->setDbValue($rs->fields('pedidoID'));
		$this->pedidoTipo->setDbValue($rs->fields('pedidoTipo'));
		$this->pedidoFecha->setDbValue($rs->fields('pedidoFecha'));
		$this->pedidoAutor->setDbValue($rs->fields('pedidoAutor'));
		$this->pedidoSucursal->setDbValue($rs->fields('pedidoSucursal'));
		$this->pedidoOrigen->setDbValue($rs->fields('pedidoOrigen'));
		$this->pedidoDestino->setDbValue($rs->fields('pedidoDestino'));
		$this->pedidoEstado->setDbValue($rs->fields('pedidoEstado'));
		$this->pedidoObservacion->setDbValue($rs->fields('pedidoObservacion'));
		$this->pedidoUltimaModificacion->setDbValue($rs->fields('pedidoUltimaModificacion'));
		$this->pedidoUltimaModificacionUsuario->setDbValue($rs->fields('pedidoUltimaModificacionUsuario'));
		$this->pedidoActivo->setDbValue($rs->fields('pedidoActivo'));
		$this->pedidoTratado->setDbValue($rs->fields('pedidoTratado'));
		$this->pedidoFechaPlanificada->setDbValue($rs->fields('pedidoFechaPlanificada'));
		$this->pedidoMotivo->setDbValue($rs->fields('pedidoMotivo'));
		$this->pedidoAnterior->setDbValue($rs->fields('pedidoAnterior'));
	}

	// Load DbValue from recordset
	function LoadDbValues(&$rs) {
		if (!$rs || !is_array($rs) && $rs->EOF) return;
		$row = is_array($rs) ? $rs : $rs->fields;
		$this->pedidoID->DbValue = $row['pedidoID'];
		$this->pedidoTipo->DbValue = $row['pedidoTipo'];
		$this->pedidoFecha->DbValue = $row['pedidoFecha'];
		$this->pedidoAutor->DbValue = $row['pedidoAutor'];
		$this->pedidoSucursal->DbValue = $row['pedidoSucursal'];
		$this->pedidoOrigen->DbValue = $row['pedidoOrigen'];
		$this->pedidoDestino->DbValue = $row['pedidoDestino'];
		$this->pedidoEstado->DbValue = $row['pedidoEstado'];
		$this->pedidoObservacion->DbValue = $row['pedidoObservacion'];
		$this->pedidoUltimaModificacion->DbValue = $row['pedidoUltimaModificacion'];
		$this->pedidoUltimaModificacionUsuario->DbValue = $row['pedidoUltimaModificacionUsuario'];
		$this->pedidoActivo->DbValue = $row['pedidoActivo'];
		$this->pedidoTratado->DbValue = $row['pedidoTratado'];
		$this->pedidoFechaPlanificada->DbValue = $row['pedidoFechaPlanificada'];
		$this->pedidoMotivo->DbValue = $row['pedidoMotivo'];
		$this->pedidoAnterior->DbValue = $row['pedidoAnterior'];
	}

	// Render row values based on field settings
	function RenderRow() {
		global $conn, $Security, $Language;
		global $gsLanguage;

		// Initialize URLs
		// Call Row_Rendering event

		$this->Row_Rendering();

		// Common render codes for all row types
		// pedidoID
		// pedidoTipo
		// pedidoFecha
		// pedidoAutor
		// pedidoSucursal
		// pedidoOrigen
		// pedidoDestino
		// pedidoEstado
		// pedidoObservacion
		// pedidoUltimaModificacion
		// pedidoUltimaModificacionUsuario
		// pedidoActivo
		// pedidoTratado
		// pedidoFechaPlanificada
		// pedidoMotivo
		// pedidoAnterior

		if ($this->RowType == EW_ROWTYPE_VIEW) { // View row

			// pedidoID
			$this->pedidoID->ViewValue = $this->pedidoID->CurrentValue;
			$this->pedidoID->ViewCustomAttributes = "";

			// pedidoTipo
			if (strval($this->pedidoTipo->CurrentValue) <> "") {
				$sFilterWrk = "`tipoId`" . ew_SearchString("=", $this->pedidoTipo->CurrentValue, EW_DATATYPE_NUMBER);
			$sSqlWrk = "SELECT `tipoId`, `tipoNombre` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `tipopedidos`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				ew_AddFilter($sWhereWrk, $sFilterWrk);
			}

			// Call Lookup selecting
			$this->Lookup_Selecting($this->pedidoTipo, $sWhereWrk);
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$this->pedidoTipo->ViewValue = $rswrk->fields('DispFld');
					$rswrk->Close();
				} else {
					$this->pedidoTipo->ViewValue = $this->pedidoTipo->CurrentValue;
				}
			} else {
				$this->pedidoTipo->ViewValue = NULL;
			}
			$this->pedidoTipo->ViewCustomAttributes = "";

			// pedidoFecha
			$this->pedidoFecha->ViewValue = $this->pedidoFecha->CurrentValue;
			$this->pedidoFecha->ViewValue = ew_FormatDateTime($this->pedidoFecha->ViewValue, 7);
			$this->pedidoFecha->ViewCustomAttributes = "";

			// pedidoAutor
			if (strval($this->pedidoAutor->CurrentValue) <> "") {
				$sFilterWrk = "`usuariosId`" . ew_SearchString("=", $this->pedidoAutor->CurrentValue, EW_DATATYPE_NUMBER);
			$sSqlWrk = "SELECT `usuariosId`, `usuariosNombre` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `usuarios`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				ew_AddFilter($sWhereWrk, $sFilterWrk);
			}

			// Call Lookup selecting
			$this->Lookup_Selecting($this->pedidoAutor, $sWhereWrk);
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$this->pedidoAutor->ViewValue = $rswrk->fields('DispFld');
					$rswrk->Close();
				} else {
					$this->pedidoAutor->ViewValue = $this->pedidoAutor->CurrentValue;
				}
			} else {
				$this->pedidoAutor->ViewValue = NULL;
			}
			$this->pedidoAutor->ViewCustomAttributes = "";

			// pedidoSucursal
			if (strval($this->pedidoSucursal->CurrentValue) <> "") {
				$sFilterWrk = "`sucursalId`" . ew_SearchString("=", $this->pedidoSucursal->CurrentValue, EW_DATATYPE_NUMBER);
			$sSqlWrk = "SELECT `sucursalId`, `sucursalNombre` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `sucursales`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				ew_AddFilter($sWhereWrk, $sFilterWrk);
			}

			// Call Lookup selecting
			$this->Lookup_Selecting($this->pedidoSucursal, $sWhereWrk);
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$this->pedidoSucursal->ViewValue = $rswrk->fields('DispFld');
					$rswrk->Close();
				} else {
					$this->pedidoSucursal->ViewValue = $this->pedidoSucursal->CurrentValue;
				}
			} else {
				$this->pedidoSucursal->ViewValue = NULL;
			}
			$this->pedidoSucursal->ViewCustomAttributes = "";

			// pedidoOrigen
			if (strval($this->pedidoOrigen->CurrentValue) <> "") {
				$sFilterWrk = "`sucursalId`" . ew_SearchString("=", $this->pedidoOrigen->CurrentValue, EW_DATATYPE_NUMBER);
			$sSqlWrk = "SELECT `sucursalId`, `sucursalNombre` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `sucursales`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				ew_AddFilter($sWhereWrk, $sFilterWrk);
			}

			// Call Lookup selecting
			$this->Lookup_Selecting($this->pedidoOrigen, $sWhereWrk);
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$this->pedidoOrigen->ViewValue = $rswrk->fields('DispFld');
					$rswrk->Close();
				} else {
					$this->pedidoOrigen->ViewValue = $this->pedidoOrigen->CurrentValue;
				}
			} else {
				$this->pedidoOrigen->ViewValue = NULL;
			}
			$this->pedidoOrigen->ViewCustomAttributes = "";

			// pedidoDestino
			if (strval($this->pedidoDestino->CurrentValue) <> "") {
				$sFilterWrk = "`sucursalId`" . ew_SearchString("=", $this->pedidoDestino->CurrentValue, EW_DATATYPE_NUMBER);
			$sSqlWrk = "SELECT `sucursalId`, `sucursalNombre` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `sucursales`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				ew_AddFilter($sWhereWrk, $sFilterWrk);
			}

			// Call Lookup selecting
			$this->Lookup_Selecting($this->pedidoDestino, $sWhereWrk);
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$this->pedidoDestino->ViewValue = $rswrk->fields('DispFld');
					$rswrk->Close();
				} else {
					$this->pedidoDestino->ViewValue = $this->pedidoDestino->CurrentValue;
				}
			} else {
				$this->pedidoDestino->ViewValue = NULL;
			}
			$this->pedidoDestino->ViewCustomAttributes = "";

			// pedidoEstado
			if (strval($this->pedidoEstado->CurrentValue) <> "") {
				$sFilterWrk = "`estadoId`" . ew_SearchString("=", $this->pedidoEstado->CurrentValue, EW_DATATYPE_NUMBER);
			$sSqlWrk = "SELECT `estadoId`, `estadoNombre` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `estados`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				ew_AddFilter($sWhereWrk, $sFilterWrk);
			}

			// Call Lookup selecting
			$this->Lookup_Selecting($this->pedidoEstado, $sWhereWrk);
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$this->pedidoEstado->ViewValue = $rswrk->fields('DispFld');
					$rswrk->Close();
				} else {
					$this->pedidoEstado->ViewValue = $this->pedidoEstado->CurrentValue;
				}
			} else {
				$this->pedidoEstado->ViewValue = NULL;
			}
			$this->pedidoEstado->ViewCustomAttributes = "";

			// pedidoObservacion
			$this->pedidoObservacion->ViewValue = $this->pedidoObservacion->CurrentValue;
			$this->pedidoObservacion->ViewCustomAttributes = "";

			// pedidoUltimaModificacion
			$this->pedidoUltimaModificacion->ViewValue = $this->pedidoUltimaModificacion->CurrentValue;
			$this->pedidoUltimaModificacion->ViewValue = ew_FormatDateTime($this->pedidoUltimaModificacion->ViewValue, 7);
			$this->pedidoUltimaModificacion->ViewCustomAttributes = "";

			// pedidoUltimaModificacionUsuario
			$this->pedidoUltimaModificacionUsuario->ViewValue = $this->pedidoUltimaModificacionUsuario->CurrentValue;
			$this->pedidoUltimaModificacionUsuario->ViewCustomAttributes = "";

			// pedidoActivo
			if (strval($this->pedidoActivo->CurrentValue) <> "") {
				switch ($this->pedidoActivo->CurrentValue) {
					case $this->pedidoActivo->FldTagValue(1):
						$this->pedidoActivo->ViewValue = $this->pedidoActivo->FldTagCaption(1) <> "" ? $this->pedidoActivo->FldTagCaption(1) : $this->pedidoActivo->CurrentValue;
						break;
					case $this->pedidoActivo->FldTagValue(2):
						$this->pedidoActivo->ViewValue = $this->pedidoActivo->FldTagCaption(2) <> "" ? $this->pedidoActivo->FldTagCaption(2) : $this->pedidoActivo->CurrentValue;
						break;
					default:
						$this->pedidoActivo->ViewValue = $this->pedidoActivo->CurrentValue;
				}
			} else {
				$this->pedidoActivo->ViewValue = NULL;
			}
			$this->pedidoActivo->ViewCustomAttributes = "";

			// pedidoTratado
			if (strval($this->pedidoTratado->CurrentValue) <> "") {
				switch ($this->pedidoTratado->CurrentValue) {
					case $this->pedidoTratado->FldTagValue(1):
						$this->pedidoTratado->ViewValue = $this->pedidoTratado->FldTagCaption(1) <> "" ? $this->pedidoTratado->FldTagCaption(1) : $this->pedidoTratado->CurrentValue;
						break;
					case $this->pedidoTratado->FldTagValue(2):
						$this->pedidoTratado->ViewValue = $this->pedidoTratado->FldTagCaption(2) <> "" ? $this->pedidoTratado->FldTagCaption(2) : $this->pedidoTratado->CurrentValue;
						break;
					default:
						$this->pedidoTratado->ViewValue = $this->pedidoTratado->CurrentValue;
				}
			} else {
				$this->pedidoTratado->ViewValue = NULL;
			}
			$this->pedidoTratado->ViewCustomAttributes = "";

			// pedidoFechaPlanificada
			$this->pedidoFechaPlanificada->ViewValue = $this->pedidoFechaPlanificada->CurrentValue;
			$this->pedidoFechaPlanificada->ViewValue = ew_FormatDateTime($this->pedidoFechaPlanificada->ViewValue, 7);
			$this->pedidoFechaPlanificada->ViewCustomAttributes = "";

			// pedidoMotivo
			if (strval($this->pedidoMotivo->CurrentValue) <> "") {
				$sFilterWrk = "`demoraId`" . ew_SearchString("=", $this->pedidoMotivo->CurrentValue, EW_DATATYPE_NUMBER);
			$sSqlWrk = "SELECT `demoraId`, `demoraNombre` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `pedidomotivodemora`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				ew_AddFilter($sWhereWrk, $sFilterWrk);
			}

			// Call Lookup selecting
			$this->Lookup_Selecting($this->pedidoMotivo, $sWhereWrk);
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$this->pedidoMotivo->ViewValue = $rswrk->fields('DispFld');
					$rswrk->Close();
				} else {
					$this->pedidoMotivo->ViewValue = $this->pedidoMotivo->CurrentValue;
				}
			} else {
				$this->pedidoMotivo->ViewValue = NULL;
			}
			$this->pedidoMotivo->ViewCustomAttributes = "";

			// pedidoAnterior
			$this->pedidoAnterior->ViewValue = $this->pedidoAnterior->CurrentValue;
			$this->pedidoAnterior->ViewCustomAttributes = "";

			// pedidoID
			$this->pedidoID->LinkCustomAttributes = "";
			$this->pedidoID->HrefValue = "";
			$this->pedidoID->TooltipValue = "";

			// pedidoTipo
			$this->pedidoTipo->LinkCustomAttributes = "";
			$this->pedidoTipo->HrefValue = "";
			$this->pedidoTipo->TooltipValue = "";

			// pedidoFecha
			$this->pedidoFecha->LinkCustomAttributes = "";
			$this->pedidoFecha->HrefValue = "";
			$this->pedidoFecha->TooltipValue = "";

			// pedidoAutor
			$this->pedidoAutor->LinkCustomAttributes = "";
			$this->pedidoAutor->HrefValue = "";
			$this->pedidoAutor->TooltipValue = "";

			// pedidoSucursal
			$this->pedidoSucursal->LinkCustomAttributes = "";
			$this->pedidoSucursal->HrefValue = "";
			$this->pedidoSucursal->TooltipValue = "";

			// pedidoOrigen
			$this->pedidoOrigen->LinkCustomAttributes = "";
			$this->pedidoOrigen->HrefValue = "";
			$this->pedidoOrigen->TooltipValue = "";

			// pedidoDestino
			$this->pedidoDestino->LinkCustomAttributes = "";
			$this->pedidoDestino->HrefValue = "";
			$this->pedidoDestino->TooltipValue = "";

			// pedidoEstado
			$this->pedidoEstado->LinkCustomAttributes = "";
			$this->pedidoEstado->HrefValue = "";
			$this->pedidoEstado->TooltipValue = "";

			// pedidoObservacion
			$this->pedidoObservacion->LinkCustomAttributes = "";
			$this->pedidoObservacion->HrefValue = "";
			$this->pedidoObservacion->TooltipValue = "";

			// pedidoUltimaModificacion
			$this->pedidoUltimaModificacion->LinkCustomAttributes = "";
			$this->pedidoUltimaModificacion->HrefValue = "";
			$this->pedidoUltimaModificacion->TooltipValue = "";

			// pedidoUltimaModificacionUsuario
			$this->pedidoUltimaModificacionUsuario->LinkCustomAttributes = "";
			$this->pedidoUltimaModificacionUsuario->HrefValue = "";
			$this->pedidoUltimaModificacionUsuario->TooltipValue = "";

			// pedidoActivo
			$this->pedidoActivo->LinkCustomAttributes = "";
			$this->pedidoActivo->HrefValue = "";
			$this->pedidoActivo->TooltipValue = "";

			// pedidoTratado
			$this->pedidoTratado->LinkCustomAttributes = "";
			$this->pedidoTratado->HrefValue = "";
			$this->pedidoTratado->TooltipValue = "";

			// pedidoFechaPlanificada
			$this->pedidoFechaPlanificada->LinkCustomAttributes = "";
			$this->pedidoFechaPlanificada->HrefValue = "";
			$this->pedidoFechaPlanificada->TooltipValue = "";

			// pedidoMotivo
			$this->pedidoMotivo->LinkCustomAttributes = "";
			$this->pedidoMotivo->HrefValue = "";
			$this->pedidoMotivo->TooltipValue = "";

			// pedidoAnterior
			$this->pedidoAnterior->LinkCustomAttributes = "";
			$this->pedidoAnterior->HrefValue = "";
			$this->pedidoAnterior->TooltipValue = "";
		} elseif ($this->RowType == EW_ROWTYPE_EDIT) { // Edit row

			// pedidoID
			$this->pedidoID->EditCustomAttributes = "";
			$this->pedidoID->EditValue = $this->pedidoID->CurrentValue;
			$this->pedidoID->ViewCustomAttributes = "";

			// pedidoTipo
			$this->pedidoTipo->EditCustomAttributes = "";
			if (trim(strval($this->pedidoTipo->CurrentValue)) == "") {
				$sFilterWrk = "0=1";
			} else {
				$sFilterWrk = "`tipoId`" . ew_SearchString("=", $this->pedidoTipo->CurrentValue, EW_DATATYPE_NUMBER);
			}
			$sSqlWrk = "SELECT `tipoId`, `tipoNombre` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld`, '' AS `SelectFilterFld`, '' AS `SelectFilterFld2`, '' AS `SelectFilterFld3`, '' AS `SelectFilterFld4` FROM `tipopedidos`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				ew_AddFilter($sWhereWrk, $sFilterWrk);
			}

			// Call Lookup selecting
			$this->Lookup_Selecting($this->pedidoTipo, $sWhereWrk);
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$rswrk = $conn->Execute($sSqlWrk);
			$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
			if ($rswrk) $rswrk->Close();
			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect"), "", "", "", "", "", "", ""));
			$this->pedidoTipo->EditValue = $arwrk;

			// pedidoFecha
			$this->pedidoFecha->EditCustomAttributes = "";
			$this->pedidoFecha->EditValue = ew_HtmlEncode(ew_FormatDateTime($this->pedidoFecha->CurrentValue, 7));
			$this->pedidoFecha->PlaceHolder = ew_HtmlEncode(ew_RemoveHtml($this->pedidoFecha->FldCaption()));

			// pedidoAutor
			$this->pedidoAutor->EditCustomAttributes = "";
			if (trim(strval($this->pedidoAutor->CurrentValue)) == "") {
				$sFilterWrk = "0=1";
			} else {
				$sFilterWrk = "`usuariosId`" . ew_SearchString("=", $this->pedidoAutor->CurrentValue, EW_DATATYPE_NUMBER);
			}
			$sSqlWrk = "SELECT `usuariosId`, `usuariosNombre` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld`, '' AS `SelectFilterFld`, '' AS `SelectFilterFld2`, '' AS `SelectFilterFld3`, '' AS `SelectFilterFld4` FROM `usuarios`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				ew_AddFilter($sWhereWrk, $sFilterWrk);
			}

			// Call Lookup selecting
			$this->Lookup_Selecting($this->pedidoAutor, $sWhereWrk);
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$rswrk = $conn->Execute($sSqlWrk);
			$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
			if ($rswrk) $rswrk->Close();
			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect"), "", "", "", "", "", "", ""));
			$this->pedidoAutor->EditValue = $arwrk;

			// pedidoSucursal
			$this->pedidoSucursal->EditCustomAttributes = "";
			if (trim(strval($this->pedidoSucursal->CurrentValue)) == "") {
				$sFilterWrk = "0=1";
			} else {
				$sFilterWrk = "`sucursalId`" . ew_SearchString("=", $this->pedidoSucursal->CurrentValue, EW_DATATYPE_NUMBER);
			}
			$sSqlWrk = "SELECT `sucursalId`, `sucursalNombre` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld`, '' AS `SelectFilterFld`, '' AS `SelectFilterFld2`, '' AS `SelectFilterFld3`, '' AS `SelectFilterFld4` FROM `sucursales`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				ew_AddFilter($sWhereWrk, $sFilterWrk);
			}

			// Call Lookup selecting
			$this->Lookup_Selecting($this->pedidoSucursal, $sWhereWrk);
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$rswrk = $conn->Execute($sSqlWrk);
			$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
			if ($rswrk) $rswrk->Close();
			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect"), "", "", "", "", "", "", ""));
			$this->pedidoSucursal->EditValue = $arwrk;

			// pedidoOrigen
			$this->pedidoOrigen->EditCustomAttributes = "";
			if (trim(strval($this->pedidoOrigen->CurrentValue)) == "") {
				$sFilterWrk = "0=1";
			} else {
				$sFilterWrk = "`sucursalId`" . ew_SearchString("=", $this->pedidoOrigen->CurrentValue, EW_DATATYPE_NUMBER);
			}
			$sSqlWrk = "SELECT `sucursalId`, `sucursalNombre` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld`, '' AS `SelectFilterFld`, '' AS `SelectFilterFld2`, '' AS `SelectFilterFld3`, '' AS `SelectFilterFld4` FROM `sucursales`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				ew_AddFilter($sWhereWrk, $sFilterWrk);
			}

			// Call Lookup selecting
			$this->Lookup_Selecting($this->pedidoOrigen, $sWhereWrk);
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$rswrk = $conn->Execute($sSqlWrk);
			$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
			if ($rswrk) $rswrk->Close();
			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect"), "", "", "", "", "", "", ""));
			$this->pedidoOrigen->EditValue = $arwrk;

			// pedidoDestino
			$this->pedidoDestino->EditCustomAttributes = "";
			if (trim(strval($this->pedidoDestino->CurrentValue)) == "") {
				$sFilterWrk = "0=1";
			} else {
				$sFilterWrk = "`sucursalId`" . ew_SearchString("=", $this->pedidoDestino->CurrentValue, EW_DATATYPE_NUMBER);
			}
			$sSqlWrk = "SELECT `sucursalId`, `sucursalNombre` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld`, '' AS `SelectFilterFld`, '' AS `SelectFilterFld2`, '' AS `SelectFilterFld3`, '' AS `SelectFilterFld4` FROM `sucursales`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				ew_AddFilter($sWhereWrk, $sFilterWrk);
			}

			// Call Lookup selecting
			$this->Lookup_Selecting($this->pedidoDestino, $sWhereWrk);
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$rswrk = $conn->Execute($sSqlWrk);
			$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
			if ($rswrk) $rswrk->Close();
			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect"), "", "", "", "", "", "", ""));
			$this->pedidoDestino->EditValue = $arwrk;

			// pedidoEstado
			$this->pedidoEstado->EditCustomAttributes = "";
			if (trim(strval($this->pedidoEstado->CurrentValue)) == "") {
				$sFilterWrk = "0=1";
			} else {
				$sFilterWrk = "`estadoId`" . ew_SearchString("=", $this->pedidoEstado->CurrentValue, EW_DATATYPE_NUMBER);
			}
			$sSqlWrk = "SELECT `estadoId`, `estadoNombre` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld`, '' AS `SelectFilterFld`, '' AS `SelectFilterFld2`, '' AS `SelectFilterFld3`, '' AS `SelectFilterFld4` FROM `estados`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				ew_AddFilter($sWhereWrk, $sFilterWrk);
			}

			// Call Lookup selecting
			$this->Lookup_Selecting($this->pedidoEstado, $sWhereWrk);
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$rswrk = $conn->Execute($sSqlWrk);
			$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
			if ($rswrk) $rswrk->Close();
			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect"), "", "", "", "", "", "", ""));
			$this->pedidoEstado->EditValue = $arwrk;

			// pedidoObservacion
			$this->pedidoObservacion->EditCustomAttributes = "";
			$this->pedidoObservacion->EditValue = ew_HtmlEncode($this->pedidoObservacion->CurrentValue);
			$this->pedidoObservacion->PlaceHolder = ew_HtmlEncode(ew_RemoveHtml($this->pedidoObservacion->FldCaption()));

			// pedidoUltimaModificacion
			$this->pedidoUltimaModificacion->EditCustomAttributes = "";
			$this->pedidoUltimaModificacion->EditValue = ew_HtmlEncode(ew_FormatDateTime($this->pedidoUltimaModificacion->CurrentValue, 7));
			$this->pedidoUltimaModificacion->PlaceHolder = ew_HtmlEncode(ew_RemoveHtml($this->pedidoUltimaModificacion->FldCaption()));

			// pedidoUltimaModificacionUsuario
			$this->pedidoUltimaModificacionUsuario->EditCustomAttributes = "";
			$this->pedidoUltimaModificacionUsuario->EditValue = ew_HtmlEncode($this->pedidoUltimaModificacionUsuario->CurrentValue);
			$this->pedidoUltimaModificacionUsuario->PlaceHolder = ew_HtmlEncode(ew_RemoveHtml($this->pedidoUltimaModificacionUsuario->FldCaption()));

			// pedidoActivo
			$this->pedidoActivo->EditCustomAttributes = "";
			$arwrk = array();
			$arwrk[] = array($this->pedidoActivo->FldTagValue(1), $this->pedidoActivo->FldTagCaption(1) <> "" ? $this->pedidoActivo->FldTagCaption(1) : $this->pedidoActivo->FldTagValue(1));
			$arwrk[] = array($this->pedidoActivo->FldTagValue(2), $this->pedidoActivo->FldTagCaption(2) <> "" ? $this->pedidoActivo->FldTagCaption(2) : $this->pedidoActivo->FldTagValue(2));
			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect")));
			$this->pedidoActivo->EditValue = $arwrk;

			// pedidoTratado
			$this->pedidoTratado->EditCustomAttributes = "";
			$arwrk = array();
			$arwrk[] = array($this->pedidoTratado->FldTagValue(1), $this->pedidoTratado->FldTagCaption(1) <> "" ? $this->pedidoTratado->FldTagCaption(1) : $this->pedidoTratado->FldTagValue(1));
			$arwrk[] = array($this->pedidoTratado->FldTagValue(2), $this->pedidoTratado->FldTagCaption(2) <> "" ? $this->pedidoTratado->FldTagCaption(2) : $this->pedidoTratado->FldTagValue(2));
			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect")));
			$this->pedidoTratado->EditValue = $arwrk;

			// pedidoFechaPlanificada
			$this->pedidoFechaPlanificada->EditCustomAttributes = "";
			$this->pedidoFechaPlanificada->EditValue = ew_HtmlEncode(ew_FormatDateTime($this->pedidoFechaPlanificada->CurrentValue, 7));
			$this->pedidoFechaPlanificada->PlaceHolder = ew_HtmlEncode(ew_RemoveHtml($this->pedidoFechaPlanificada->FldCaption()));

			// pedidoMotivo
			$this->pedidoMotivo->EditCustomAttributes = "";
			if (trim(strval($this->pedidoMotivo->CurrentValue)) == "") {
				$sFilterWrk = "0=1";
			} else {
				$sFilterWrk = "`demoraId`" . ew_SearchString("=", $this->pedidoMotivo->CurrentValue, EW_DATATYPE_NUMBER);
			}
			$sSqlWrk = "SELECT `demoraId`, `demoraNombre` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld`, '' AS `SelectFilterFld`, '' AS `SelectFilterFld2`, '' AS `SelectFilterFld3`, '' AS `SelectFilterFld4` FROM `pedidomotivodemora`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				ew_AddFilter($sWhereWrk, $sFilterWrk);
			}

			// Call Lookup selecting
			$this->Lookup_Selecting($this->pedidoMotivo, $sWhereWrk);
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$rswrk = $conn->Execute($sSqlWrk);
			$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
			if ($rswrk) $rswrk->Close();
			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect"), "", "", "", "", "", "", ""));
			$this->pedidoMotivo->EditValue = $arwrk;

			// pedidoAnterior
			$this->pedidoAnterior->EditCustomAttributes = "";
			$this->pedidoAnterior->EditValue = ew_HtmlEncode($this->pedidoAnterior->CurrentValue);
			$this->pedidoAnterior->PlaceHolder = ew_HtmlEncode(ew_RemoveHtml($this->pedidoAnterior->FldCaption()));

			// Edit refer script
			// pedidoID

			$this->pedidoID->HrefValue = "";

			// pedidoTipo
			$this->pedidoTipo->HrefValue = "";

			// pedidoFecha
			$this->pedidoFecha->HrefValue = "";

			// pedidoAutor
			$this->pedidoAutor->HrefValue = "";

			// pedidoSucursal
			$this->pedidoSucursal->HrefValue = "";

			// pedidoOrigen
			$this->pedidoOrigen->HrefValue = "";

			// pedidoDestino
			$this->pedidoDestino->HrefValue = "";

			// pedidoEstado
			$this->pedidoEstado->HrefValue = "";

			// pedidoObservacion
			$this->pedidoObservacion->HrefValue = "";

			// pedidoUltimaModificacion
			$this->pedidoUltimaModificacion->HrefValue = "";

			// pedidoUltimaModificacionUsuario
			$this->pedidoUltimaModificacionUsuario->HrefValue = "";

			// pedidoActivo
			$this->pedidoActivo->HrefValue = "";

			// pedidoTratado
			$this->pedidoTratado->HrefValue = "";

			// pedidoFechaPlanificada
			$this->pedidoFechaPlanificada->HrefValue = "";

			// pedidoMotivo
			$this->pedidoMotivo->HrefValue = "";

			// pedidoAnterior
			$this->pedidoAnterior->HrefValue = "";
		}
		if ($this->RowType == EW_ROWTYPE_ADD ||
			$this->RowType == EW_ROWTYPE_EDIT ||
			$this->RowType == EW_ROWTYPE_SEARCH) { // Add / Edit / Search row
			$this->SetupFieldTitles();
		}

		// Call Row Rendered event
		if ($this->RowType <> EW_ROWTYPE_AGGREGATEINIT)
			$this->Row_Rendered();
	}

	// Validate form
	function ValidateForm() {
		global $Language, $gsFormError;

		// Initialize form error message
		$gsFormError = "";

		// Check if validation required
		if (!EW_SERVER_VALIDATE)
			return ($gsFormError == "");
		if (!ew_CheckEuroDate($this->pedidoFecha->FormValue)) {
			ew_AddMessage($gsFormError, $this->pedidoFecha->FldErrMsg());
		}
		if (!ew_CheckEuroDate($this->pedidoUltimaModificacion->FormValue)) {
			ew_AddMessage($gsFormError, $this->pedidoUltimaModificacion->FldErrMsg());
		}
		if (!ew_CheckInteger($this->pedidoUltimaModificacionUsuario->FormValue)) {
			ew_AddMessage($gsFormError, $this->pedidoUltimaModificacionUsuario->FldErrMsg());
		}
		if (!ew_CheckEuroDate($this->pedidoFechaPlanificada->FormValue)) {
			ew_AddMessage($gsFormError, $this->pedidoFechaPlanificada->FldErrMsg());
		}
		if (!ew_CheckInteger($this->pedidoAnterior->FormValue)) {
			ew_AddMessage($gsFormError, $this->pedidoAnterior->FldErrMsg());
		}

		// Validate detail grid
		$DetailTblVar = explode(",", $this->getCurrentDetailTable());
		if (in_array("pedidodetalle", $DetailTblVar) && $GLOBALS["pedidodetalle"]->DetailEdit) {
			if (!isset($GLOBALS["pedidodetalle_grid"])) $GLOBALS["pedidodetalle_grid"] = new cpedidodetalle_grid(); // get detail page object
			$GLOBALS["pedidodetalle_grid"]->ValidateGridForm();
		}
		if (in_array("pedidohistorial", $DetailTblVar) && $GLOBALS["pedidohistorial"]->DetailEdit) {
			if (!isset($GLOBALS["pedidohistorial_grid"])) $GLOBALS["pedidohistorial_grid"] = new cpedidohistorial_grid(); // get detail page object
			$GLOBALS["pedidohistorial_grid"]->ValidateGridForm();
		}

		// Return validate result
		$ValidateForm = ($gsFormError == "");

		// Call Form_CustomValidate event
		$sFormCustomError = "";
		$ValidateForm = $ValidateForm && $this->Form_CustomValidate($sFormCustomError);
		if ($sFormCustomError <> "") {
			ew_AddMessage($gsFormError, $sFormCustomError);
		}
		return $ValidateForm;
	}

	// Update record based on key values
	function EditRow() {
		global $conn, $Security, $Language;
		$sFilter = $this->KeyFilter();
		$this->CurrentFilter = $sFilter;
		$sSql = $this->SQL();
		$conn->raiseErrorFn = 'ew_ErrorFn';
		$rs = $conn->Execute($sSql);
		$conn->raiseErrorFn = '';
		if ($rs === FALSE)
			return FALSE;
		if ($rs->EOF) {
			$EditRow = FALSE; // Update Failed
		} else {

			// Begin transaction
			if ($this->getCurrentDetailTable() <> "")
				$conn->BeginTrans();

			// Save old values
			$rsold = &$rs->fields;
			$this->LoadDbValues($rsold);
			$rsnew = array();

			// pedidoTipo
			$this->pedidoTipo->SetDbValueDef($rsnew, $this->pedidoTipo->CurrentValue, NULL, $this->pedidoTipo->ReadOnly);

			// pedidoFecha
			$this->pedidoFecha->SetDbValueDef($rsnew, ew_UnFormatDateTime($this->pedidoFecha->CurrentValue, 7), NULL, $this->pedidoFecha->ReadOnly);

			// pedidoAutor
			$this->pedidoAutor->SetDbValueDef($rsnew, $this->pedidoAutor->CurrentValue, NULL, $this->pedidoAutor->ReadOnly);

			// pedidoSucursal
			$this->pedidoSucursal->SetDbValueDef($rsnew, $this->pedidoSucursal->CurrentValue, NULL, $this->pedidoSucursal->ReadOnly);

			// pedidoOrigen
			$this->pedidoOrigen->SetDbValueDef($rsnew, $this->pedidoOrigen->CurrentValue, NULL, $this->pedidoOrigen->ReadOnly);

			// pedidoDestino
			$this->pedidoDestino->SetDbValueDef($rsnew, $this->pedidoDestino->CurrentValue, NULL, $this->pedidoDestino->ReadOnly);

			// pedidoEstado
			$this->pedidoEstado->SetDbValueDef($rsnew, $this->pedidoEstado->CurrentValue, NULL, $this->pedidoEstado->ReadOnly);

			// pedidoObservacion
			$this->pedidoObservacion->SetDbValueDef($rsnew, $this->pedidoObservacion->CurrentValue, NULL, $this->pedidoObservacion->ReadOnly);

			// pedidoUltimaModificacion
			$this->pedidoUltimaModificacion->SetDbValueDef($rsnew, ew_UnFormatDateTime($this->pedidoUltimaModificacion->CurrentValue, 7), NULL, $this->pedidoUltimaModificacion->ReadOnly);

			// pedidoUltimaModificacionUsuario
			$this->pedidoUltimaModificacionUsuario->SetDbValueDef($rsnew, $this->pedidoUltimaModificacionUsuario->CurrentValue, NULL, $this->pedidoUltimaModificacionUsuario->ReadOnly);

			// pedidoActivo
			$this->pedidoActivo->SetDbValueDef($rsnew, $this->pedidoActivo->CurrentValue, NULL, $this->pedidoActivo->ReadOnly);

			// pedidoTratado
			$this->pedidoTratado->SetDbValueDef($rsnew, $this->pedidoTratado->CurrentValue, NULL, $this->pedidoTratado->ReadOnly);

			// pedidoFechaPlanificada
			$this->pedidoFechaPlanificada->SetDbValueDef($rsnew, ew_UnFormatDateTime($this->pedidoFechaPlanificada->CurrentValue, 7), NULL, $this->pedidoFechaPlanificada->ReadOnly);

			// pedidoMotivo
			$this->pedidoMotivo->SetDbValueDef($rsnew, $this->pedidoMotivo->CurrentValue, 0, $this->pedidoMotivo->ReadOnly);

			// pedidoAnterior
			$this->pedidoAnterior->SetDbValueDef($rsnew, $this->pedidoAnterior->CurrentValue, NULL, $this->pedidoAnterior->ReadOnly);

			// Call Row Updating event
			$bUpdateRow = $this->Row_Updating($rsold, $rsnew);
			if ($bUpdateRow) {
				$conn->raiseErrorFn = 'ew_ErrorFn';
				if (count($rsnew) > 0)
					$EditRow = $this->Update($rsnew, "", $rsold);
				else
					$EditRow = TRUE; // No field to update
				$conn->raiseErrorFn = '';
				if ($EditRow) {
				}

				// Update detail records
				if ($EditRow) {
					$DetailTblVar = explode(",", $this->getCurrentDetailTable());
					if (in_array("pedidodetalle", $DetailTblVar) && $GLOBALS["pedidodetalle"]->DetailEdit) {
						if (!isset($GLOBALS["pedidodetalle_grid"])) $GLOBALS["pedidodetalle_grid"] = new cpedidodetalle_grid(); // Get detail page object
						$EditRow = $GLOBALS["pedidodetalle_grid"]->GridUpdate();
					}
					if (in_array("pedidohistorial", $DetailTblVar) && $GLOBALS["pedidohistorial"]->DetailEdit) {
						if (!isset($GLOBALS["pedidohistorial_grid"])) $GLOBALS["pedidohistorial_grid"] = new cpedidohistorial_grid(); // Get detail page object
						$EditRow = $GLOBALS["pedidohistorial_grid"]->GridUpdate();
					}
				}

				// Commit/Rollback transaction
				if ($this->getCurrentDetailTable() <> "") {
					if ($EditRow) {
						$conn->CommitTrans(); // Commit transaction
					} else {
						$conn->RollbackTrans(); // Rollback transaction
					}
				}
			} else {
				if ($this->getSuccessMessage() <> "" || $this->getFailureMessage() <> "") {

					// Use the message, do nothing
				} elseif ($this->CancelMessage <> "") {
					$this->setFailureMessage($this->CancelMessage);
					$this->CancelMessage = "";
				} else {
					$this->setFailureMessage($Language->Phrase("UpdateCancelled"));
				}
				$EditRow = FALSE;
			}
		}

		// Call Row_Updated event
		if ($EditRow)
			$this->Row_Updated($rsold, $rsnew);
		$rs->Close();
		return $EditRow;
	}

	// Set up detail parms based on QueryString
	function SetUpDetailParms() {

		// Get the keys for master table
		if (isset($_GET[EW_TABLE_SHOW_DETAIL])) {
			$sDetailTblVar = $_GET[EW_TABLE_SHOW_DETAIL];
			$this->setCurrentDetailTable($sDetailTblVar);
		} else {
			$sDetailTblVar = $this->getCurrentDetailTable();
		}
		if ($sDetailTblVar <> "") {
			$DetailTblVar = explode(",", $sDetailTblVar);
			if (in_array("pedidodetalle", $DetailTblVar)) {
				if (!isset($GLOBALS["pedidodetalle_grid"]))
					$GLOBALS["pedidodetalle_grid"] = new cpedidodetalle_grid;
				if ($GLOBALS["pedidodetalle_grid"]->DetailEdit) {
					$GLOBALS["pedidodetalle_grid"]->CurrentMode = "edit";
					$GLOBALS["pedidodetalle_grid"]->CurrentAction = "gridedit";

					// Save current master table to detail table
					$GLOBALS["pedidodetalle_grid"]->setCurrentMasterTable($this->TableVar);
					$GLOBALS["pedidodetalle_grid"]->setStartRecordNumber(1);
					$GLOBALS["pedidodetalle_grid"]->detallePedido->FldIsDetailKey = TRUE;
					$GLOBALS["pedidodetalle_grid"]->detallePedido->CurrentValue = $this->pedidoID->CurrentValue;
					$GLOBALS["pedidodetalle_grid"]->detallePedido->setSessionValue($GLOBALS["pedidodetalle_grid"]->detallePedido->CurrentValue);
				}
			}
			if (in_array("pedidohistorial", $DetailTblVar)) {
				if (!isset($GLOBALS["pedidohistorial_grid"]))
					$GLOBALS["pedidohistorial_grid"] = new cpedidohistorial_grid;
				if ($GLOBALS["pedidohistorial_grid"]->DetailEdit) {
					$GLOBALS["pedidohistorial_grid"]->CurrentMode = "edit";
					$GLOBALS["pedidohistorial_grid"]->CurrentAction = "gridedit";

					// Save current master table to detail table
					$GLOBALS["pedidohistorial_grid"]->setCurrentMasterTable($this->TableVar);
					$GLOBALS["pedidohistorial_grid"]->setStartRecordNumber(1);
					$GLOBALS["pedidohistorial_grid"]->historialPedido->FldIsDetailKey = TRUE;
					$GLOBALS["pedidohistorial_grid"]->historialPedido->CurrentValue = $this->pedidoID->CurrentValue;
					$GLOBALS["pedidohistorial_grid"]->historialPedido->setSessionValue($GLOBALS["pedidohistorial_grid"]->historialPedido->CurrentValue);
				}
			}
		}
	}

	// Set up Breadcrumb
	function SetupBreadcrumb() {
		global $Breadcrumb, $Language;
		$Breadcrumb = new cBreadcrumb();
		$Breadcrumb->Add("list", $this->TableVar, "pedidoslist.php", $this->TableVar, TRUE);
		$PageId = "edit";
		$Breadcrumb->Add("edit", $PageId, ew_CurrentUrl());
	}

	// Page Load event
	function Page_Load() {

		//echo "Page Load";
	}

	// Page Unload event
	function Page_Unload() {

		//echo "Page Unload";
	}

	// Page Redirecting event
	function Page_Redirecting(&$url) {

		// Example:
		//$url = "your URL";

	}

	// Message Showing event
	// $type = ''|'success'|'failure'|'warning'
	function Message_Showing(&$msg, $type) {
		if ($type == 'success') {

			//$msg = "your success message";
		} elseif ($type == 'failure') {

			//$msg = "your failure message";
		} elseif ($type == 'warning') {

			//$msg = "your warning message";
		} else {

			//$msg = "your message";
		}
	}

	// Page Render event
	function Page_Render() {

		//echo "Page Render";
	}

	// Page Data Rendering event
	function Page_DataRendering(&$header) {

		// Example:
		//$header = "your header";

	}

	// Page Data Rendered event
	function Page_DataRendered(&$footer) {

		// Example:
		//$footer = "your footer";

	}

	// Form Custom Validate event
	function Form_CustomValidate(&$CustomError) {

		// Return error message in CustomError
		return TRUE;
	}
}
?>
<?php ew_Header(FALSE) ?>
<?php

// Create page object
if (!isset($pedidos_edit)) $pedidos_edit = new cpedidos_edit();

// Page init
$pedidos_edit->Page_Init();

// Page main
$pedidos_edit->Page_Main();

// Global Page Rendering event (in userfn*.php)
Page_Rendering();

// Page Rendering event
$pedidos_edit->Page_Render();
?>
<?php include_once "header.php" ?>
<script type="text/javascript">

// Page object
var pedidos_edit = new ew_Page("pedidos_edit");
pedidos_edit.PageID = "edit"; // Page ID
var EW_PAGE_ID = pedidos_edit.PageID; // For backward compatibility

// Form object
var fpedidosedit = new ew_Form("fpedidosedit");

// Validate form
fpedidosedit.Validate = function() {
	if (!this.ValidateRequired)
		return true; // Ignore validation
	var $ = jQuery, fobj = this.GetForm(), $fobj = $(fobj);
	this.PostAutoSuggest();
	if ($fobj.find("#a_confirm").val() == "F")
		return true;
	var elm, felm, uelm, addcnt = 0;
	var $k = $fobj.find("#" + this.FormKeyCountName); // Get key_count
	var rowcnt = ($k[0]) ? parseInt($k.val(), 10) : 1;
	var startcnt = (rowcnt == 0) ? 0 : 1; // Check rowcnt == 0 => Inline-Add
	var gridinsert = $fobj.find("#a_list").val() == "gridinsert";
	for (var i = startcnt; i <= rowcnt; i++) {
		var infix = ($k[0]) ? String(i) : "";
		$fobj.data("rowindex", infix);
			elm = this.GetElements("x" + infix + "_pedidoFecha");
			if (elm && !ew_CheckEuroDate(elm.value))
				return this.OnError(elm, "<?php echo ew_JsEncode2($pedidos->pedidoFecha->FldErrMsg()) ?>");
			elm = this.GetElements("x" + infix + "_pedidoUltimaModificacion");
			if (elm && !ew_CheckEuroDate(elm.value))
				return this.OnError(elm, "<?php echo ew_JsEncode2($pedidos->pedidoUltimaModificacion->FldErrMsg()) ?>");
			elm = this.GetElements("x" + infix + "_pedidoUltimaModificacionUsuario");
			if (elm && !ew_CheckInteger(elm.value))
				return this.OnError(elm, "<?php echo ew_JsEncode2($pedidos->pedidoUltimaModificacionUsuario->FldErrMsg()) ?>");
			elm = this.GetElements("x" + infix + "_pedidoFechaPlanificada");
			if (elm && !ew_CheckEuroDate(elm.value))
				return this.OnError(elm, "<?php echo ew_JsEncode2($pedidos->pedidoFechaPlanificada->FldErrMsg()) ?>");
			elm = this.GetElements("x" + infix + "_pedidoAnterior");
			if (elm && !ew_CheckInteger(elm.value))
				return this.OnError(elm, "<?php echo ew_JsEncode2($pedidos->pedidoAnterior->FldErrMsg()) ?>");

			// Set up row object
			ew_ElementsToRow(fobj);

			// Fire Form_CustomValidate event
			if (!this.Form_CustomValidate(fobj))
				return false;
	}

	// Process detail forms
	var dfs = $fobj.find("input[name='detailpage']").get();
	for (var i = 0; i < dfs.length; i++) {
		var df = dfs[i], val = df.value;
		if (val && ewForms[val])
			if (!ewForms[val].Validate())
				return false;
	}
	return true;
}

// Form_CustomValidate event
fpedidosedit.Form_CustomValidate = 
 function(fobj) { // DO NOT CHANGE THIS LINE!

 	// Your custom validation code here, return false if invalid. 
 	return true;
 }

// Use JavaScript validation or not
<?php if (EW_CLIENT_VALIDATE) { ?>
fpedidosedit.ValidateRequired = true;
<?php } else { ?>
fpedidosedit.ValidateRequired = false; 
<?php } ?>

// Dynamic selection lists
fpedidosedit.Lists["x_pedidoTipo"] = {"LinkField":"x_tipoId","Ajax":true,"AutoFill":false,"DisplayFields":["x_tipoNombre","","",""],"ParentFields":[],"FilterFields":[],"Options":[]};
fpedidosedit.Lists["x_pedidoAutor"] = {"LinkField":"x_usuariosId","Ajax":true,"AutoFill":false,"DisplayFields":["x_usuariosNombre","","",""],"ParentFields":[],"FilterFields":[],"Options":[]};
fpedidosedit.Lists["x_pedidoSucursal"] = {"LinkField":"x_sucursalId","Ajax":true,"AutoFill":false,"DisplayFields":["x_sucursalNombre","","",""],"ParentFields":[],"FilterFields":[],"Options":[]};
fpedidosedit.Lists["x_pedidoOrigen"] = {"LinkField":"x_sucursalId","Ajax":true,"AutoFill":false,"DisplayFields":["x_sucursalNombre","","",""],"ParentFields":[],"FilterFields":[],"Options":[]};
fpedidosedit.Lists["x_pedidoDestino"] = {"LinkField":"x_sucursalId","Ajax":true,"AutoFill":false,"DisplayFields":["x_sucursalNombre","","",""],"ParentFields":[],"FilterFields":[],"Options":[]};
fpedidosedit.Lists["x_pedidoEstado"] = {"LinkField":"x_estadoId","Ajax":true,"AutoFill":false,"DisplayFields":["x_estadoNombre","","",""],"ParentFields":[],"FilterFields":[],"Options":[]};
fpedidosedit.Lists["x_pedidoMotivo"] = {"LinkField":"x_demoraId","Ajax":true,"AutoFill":false,"DisplayFields":["x_demoraNombre","","",""],"ParentFields":[],"FilterFields":[],"Options":[]};

// Form object for search
</script>
<script type="text/javascript">

// Write your client script here, no need to add script tags.
</script>
<?php $Breadcrumb->Render(); ?>
<?php $pedidos_edit->ShowPageHeader(); ?>
<?php
$pedidos_edit->ShowMessage();
?>
<form name="fpedidosedit" id="fpedidosedit" class="ewForm form-horizontal" action="<?php echo ew_CurrentPage() ?>" method="post">
<input type="hidden" name="t" value="pedidos">
<input type="hidden" name="a_edit" id="a_edit" value="U">
<table class="ewGrid"><tr><td>
<table id="tbl_pedidosedit" class="table table-bordered table-striped">
<?php if ($pedidos->pedidoID->Visible) { // pedidoID ?>
	<tr id="r_pedidoID">
		<td><span id="elh_pedidos_pedidoID"><?php echo $pedidos->pedidoID->FldCaption() ?></span></td>
		<td<?php echo $pedidos->pedidoID->CellAttributes() ?>>
<span id="el_pedidos_pedidoID" class="control-group">
<span<?php echo $pedidos->pedidoID->ViewAttributes() ?>>
<?php echo $pedidos->pedidoID->EditValue ?></span>
</span>
<input type="hidden" data-field="x_pedidoID" name="x_pedidoID" id="x_pedidoID" value="<?php echo ew_HtmlEncode($pedidos->pedidoID->CurrentValue) ?>">
<?php echo $pedidos->pedidoID->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($pedidos->pedidoTipo->Visible) { // pedidoTipo ?>
	<tr id="r_pedidoTipo">
		<td><span id="elh_pedidos_pedidoTipo"><?php echo $pedidos->pedidoTipo->FldCaption() ?></span></td>
		<td<?php echo $pedidos->pedidoTipo->CellAttributes() ?>>
<span id="el_pedidos_pedidoTipo" class="control-group">
<select data-field="x_pedidoTipo" id="x_pedidoTipo" name="x_pedidoTipo"<?php echo $pedidos->pedidoTipo->EditAttributes() ?>>
<?php
if (is_array($pedidos->pedidoTipo->EditValue)) {
	$arwrk = $pedidos->pedidoTipo->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($pedidos->pedidoTipo->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
?>
</select>
<?php
$sSqlWrk = "SELECT `tipoId`, `tipoNombre` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `tipopedidos`";
$sWhereWrk = "";

// Call Lookup selecting
$pedidos->Lookup_Selecting($pedidos->pedidoTipo, $sWhereWrk);
if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
?>
<input type="hidden" name="s_x_pedidoTipo" id="s_x_pedidoTipo" value="s=<?php echo ew_Encrypt($sSqlWrk) ?>&amp;f0=<?php echo ew_Encrypt("`tipoId` = {filter_value}"); ?>&amp;t0=3">
</span>
<?php echo $pedidos->pedidoTipo->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($pedidos->pedidoFecha->Visible) { // pedidoFecha ?>
	<tr id="r_pedidoFecha">
		<td><span id="elh_pedidos_pedidoFecha"><?php echo $pedidos->pedidoFecha->FldCaption() ?></span></td>
		<td<?php echo $pedidos->pedidoFecha->CellAttributes() ?>>
<span id="el_pedidos_pedidoFecha" class="control-group">
<input type="text" data-field="x_pedidoFecha" name="x_pedidoFecha" id="x_pedidoFecha" placeholder="<?php echo $pedidos->pedidoFecha->PlaceHolder ?>" value="<?php echo $pedidos->pedidoFecha->EditValue ?>"<?php echo $pedidos->pedidoFecha->EditAttributes() ?>>
<?php if (!$pedidos->pedidoFecha->ReadOnly && !$pedidos->pedidoFecha->Disabled && @$pedidos->pedidoFecha->EditAttrs["readonly"] == "" && @$pedidos->pedidoFecha->EditAttrs["disabled"] == "") { ?>
<button id="cal_x_pedidoFecha" name="cal_x_pedidoFecha" class="btn" type="button"><img src="phpimages/calendar.png" alt="<?php echo $Language->Phrase("PickDate") ?>" title="<?php echo $Language->Phrase("PickDate") ?>" style="border: 0;"></button><script type="text/javascript">
ew_CreateCalendar("fpedidosedit", "x_pedidoFecha", "%d/%m/%Y");
</script>
<?php } ?>
</span>
<?php echo $pedidos->pedidoFecha->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($pedidos->pedidoAutor->Visible) { // pedidoAutor ?>
	<tr id="r_pedidoAutor">
		<td><span id="elh_pedidos_pedidoAutor"><?php echo $pedidos->pedidoAutor->FldCaption() ?></span></td>
		<td<?php echo $pedidos->pedidoAutor->CellAttributes() ?>>
<span id="el_pedidos_pedidoAutor" class="control-group">
<select data-field="x_pedidoAutor" id="x_pedidoAutor" name="x_pedidoAutor"<?php echo $pedidos->pedidoAutor->EditAttributes() ?>>
<?php
if (is_array($pedidos->pedidoAutor->EditValue)) {
	$arwrk = $pedidos->pedidoAutor->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($pedidos->pedidoAutor->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
?>
</select>
<?php
$sSqlWrk = "SELECT `usuariosId`, `usuariosNombre` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `usuarios`";
$sWhereWrk = "";

// Call Lookup selecting
$pedidos->Lookup_Selecting($pedidos->pedidoAutor, $sWhereWrk);
if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
?>
<input type="hidden" name="s_x_pedidoAutor" id="s_x_pedidoAutor" value="s=<?php echo ew_Encrypt($sSqlWrk) ?>&amp;f0=<?php echo ew_Encrypt("`usuariosId` = {filter_value}"); ?>&amp;t0=3">
</span>
<?php echo $pedidos->pedidoAutor->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($pedidos->pedidoSucursal->Visible) { // pedidoSucursal ?>
	<tr id="r_pedidoSucursal">
		<td><span id="elh_pedidos_pedidoSucursal"><?php echo $pedidos->pedidoSucursal->FldCaption() ?></span></td>
		<td<?php echo $pedidos->pedidoSucursal->CellAttributes() ?>>
<span id="el_pedidos_pedidoSucursal" class="control-group">
<select data-field="x_pedidoSucursal" id="x_pedidoSucursal" name="x_pedidoSucursal"<?php echo $pedidos->pedidoSucursal->EditAttributes() ?>>
<?php
if (is_array($pedidos->pedidoSucursal->EditValue)) {
	$arwrk = $pedidos->pedidoSucursal->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($pedidos->pedidoSucursal->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
?>
</select>
<?php
$sSqlWrk = "SELECT `sucursalId`, `sucursalNombre` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `sucursales`";
$sWhereWrk = "";

// Call Lookup selecting
$pedidos->Lookup_Selecting($pedidos->pedidoSucursal, $sWhereWrk);
if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
?>
<input type="hidden" name="s_x_pedidoSucursal" id="s_x_pedidoSucursal" value="s=<?php echo ew_Encrypt($sSqlWrk) ?>&amp;f0=<?php echo ew_Encrypt("`sucursalId` = {filter_value}"); ?>&amp;t0=3">
</span>
<?php echo $pedidos->pedidoSucursal->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($pedidos->pedidoOrigen->Visible) { // pedidoOrigen ?>
	<tr id="r_pedidoOrigen">
		<td><span id="elh_pedidos_pedidoOrigen"><?php echo $pedidos->pedidoOrigen->FldCaption() ?></span></td>
		<td<?php echo $pedidos->pedidoOrigen->CellAttributes() ?>>
<span id="el_pedidos_pedidoOrigen" class="control-group">
<select data-field="x_pedidoOrigen" id="x_pedidoOrigen" name="x_pedidoOrigen"<?php echo $pedidos->pedidoOrigen->EditAttributes() ?>>
<?php
if (is_array($pedidos->pedidoOrigen->EditValue)) {
	$arwrk = $pedidos->pedidoOrigen->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($pedidos->pedidoOrigen->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
?>
</select>
<?php
$sSqlWrk = "SELECT `sucursalId`, `sucursalNombre` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `sucursales`";
$sWhereWrk = "";

// Call Lookup selecting
$pedidos->Lookup_Selecting($pedidos->pedidoOrigen, $sWhereWrk);
if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
?>
<input type="hidden" name="s_x_pedidoOrigen" id="s_x_pedidoOrigen" value="s=<?php echo ew_Encrypt($sSqlWrk) ?>&amp;f0=<?php echo ew_Encrypt("`sucursalId` = {filter_value}"); ?>&amp;t0=3">
</span>
<?php echo $pedidos->pedidoOrigen->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($pedidos->pedidoDestino->Visible) { // pedidoDestino ?>
	<tr id="r_pedidoDestino">
		<td><span id="elh_pedidos_pedidoDestino"><?php echo $pedidos->pedidoDestino->FldCaption() ?></span></td>
		<td<?php echo $pedidos->pedidoDestino->CellAttributes() ?>>
<span id="el_pedidos_pedidoDestino" class="control-group">
<select data-field="x_pedidoDestino" id="x_pedidoDestino" name="x_pedidoDestino"<?php echo $pedidos->pedidoDestino->EditAttributes() ?>>
<?php
if (is_array($pedidos->pedidoDestino->EditValue)) {
	$arwrk = $pedidos->pedidoDestino->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($pedidos->pedidoDestino->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
?>
</select>
<?php
$sSqlWrk = "SELECT `sucursalId`, `sucursalNombre` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `sucursales`";
$sWhereWrk = "";

// Call Lookup selecting
$pedidos->Lookup_Selecting($pedidos->pedidoDestino, $sWhereWrk);
if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
?>
<input type="hidden" name="s_x_pedidoDestino" id="s_x_pedidoDestino" value="s=<?php echo ew_Encrypt($sSqlWrk) ?>&amp;f0=<?php echo ew_Encrypt("`sucursalId` = {filter_value}"); ?>&amp;t0=3">
</span>
<?php echo $pedidos->pedidoDestino->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($pedidos->pedidoEstado->Visible) { // pedidoEstado ?>
	<tr id="r_pedidoEstado">
		<td><span id="elh_pedidos_pedidoEstado"><?php echo $pedidos->pedidoEstado->FldCaption() ?></span></td>
		<td<?php echo $pedidos->pedidoEstado->CellAttributes() ?>>
<span id="el_pedidos_pedidoEstado" class="control-group">
<select data-field="x_pedidoEstado" id="x_pedidoEstado" name="x_pedidoEstado"<?php echo $pedidos->pedidoEstado->EditAttributes() ?>>
<?php
if (is_array($pedidos->pedidoEstado->EditValue)) {
	$arwrk = $pedidos->pedidoEstado->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($pedidos->pedidoEstado->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
?>
</select>
<?php
$sSqlWrk = "SELECT `estadoId`, `estadoNombre` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `estados`";
$sWhereWrk = "";

// Call Lookup selecting
$pedidos->Lookup_Selecting($pedidos->pedidoEstado, $sWhereWrk);
if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
?>
<input type="hidden" name="s_x_pedidoEstado" id="s_x_pedidoEstado" value="s=<?php echo ew_Encrypt($sSqlWrk) ?>&amp;f0=<?php echo ew_Encrypt("`estadoId` = {filter_value}"); ?>&amp;t0=3">
</span>
<?php echo $pedidos->pedidoEstado->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($pedidos->pedidoObservacion->Visible) { // pedidoObservacion ?>
	<tr id="r_pedidoObservacion">
		<td><span id="elh_pedidos_pedidoObservacion"><?php echo $pedidos->pedidoObservacion->FldCaption() ?></span></td>
		<td<?php echo $pedidos->pedidoObservacion->CellAttributes() ?>>
<span id="el_pedidos_pedidoObservacion" class="control-group">
<input type="text" data-field="x_pedidoObservacion" name="x_pedidoObservacion" id="x_pedidoObservacion" size="30" maxlength="255" placeholder="<?php echo $pedidos->pedidoObservacion->PlaceHolder ?>" value="<?php echo $pedidos->pedidoObservacion->EditValue ?>"<?php echo $pedidos->pedidoObservacion->EditAttributes() ?>>
</span>
<?php echo $pedidos->pedidoObservacion->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($pedidos->pedidoUltimaModificacion->Visible) { // pedidoUltimaModificacion ?>
	<tr id="r_pedidoUltimaModificacion">
		<td><span id="elh_pedidos_pedidoUltimaModificacion"><?php echo $pedidos->pedidoUltimaModificacion->FldCaption() ?></span></td>
		<td<?php echo $pedidos->pedidoUltimaModificacion->CellAttributes() ?>>
<span id="el_pedidos_pedidoUltimaModificacion" class="control-group">
<input type="text" data-field="x_pedidoUltimaModificacion" name="x_pedidoUltimaModificacion" id="x_pedidoUltimaModificacion" placeholder="<?php echo $pedidos->pedidoUltimaModificacion->PlaceHolder ?>" value="<?php echo $pedidos->pedidoUltimaModificacion->EditValue ?>"<?php echo $pedidos->pedidoUltimaModificacion->EditAttributes() ?>>
</span>
<?php echo $pedidos->pedidoUltimaModificacion->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($pedidos->pedidoUltimaModificacionUsuario->Visible) { // pedidoUltimaModificacionUsuario ?>
	<tr id="r_pedidoUltimaModificacionUsuario">
		<td><span id="elh_pedidos_pedidoUltimaModificacionUsuario"><?php echo $pedidos->pedidoUltimaModificacionUsuario->FldCaption() ?></span></td>
		<td<?php echo $pedidos->pedidoUltimaModificacionUsuario->CellAttributes() ?>>
<span id="el_pedidos_pedidoUltimaModificacionUsuario" class="control-group">
<input type="text" data-field="x_pedidoUltimaModificacionUsuario" name="x_pedidoUltimaModificacionUsuario" id="x_pedidoUltimaModificacionUsuario" size="30" placeholder="<?php echo $pedidos->pedidoUltimaModificacionUsuario->PlaceHolder ?>" value="<?php echo $pedidos->pedidoUltimaModificacionUsuario->EditValue ?>"<?php echo $pedidos->pedidoUltimaModificacionUsuario->EditAttributes() ?>>
</span>
<?php echo $pedidos->pedidoUltimaModificacionUsuario->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($pedidos->pedidoActivo->Visible) { // pedidoActivo ?>
	<tr id="r_pedidoActivo">
		<td><span id="elh_pedidos_pedidoActivo"><?php echo $pedidos->pedidoActivo->FldCaption() ?></span></td>
		<td<?php echo $pedidos->pedidoActivo->CellAttributes() ?>>
<span id="el_pedidos_pedidoActivo" class="control-group">
<select data-field="x_pedidoActivo" id="x_pedidoActivo" name="x_pedidoActivo"<?php echo $pedidos->pedidoActivo->EditAttributes() ?>>
<?php
if (is_array($pedidos->pedidoActivo->EditValue)) {
	$arwrk = $pedidos->pedidoActivo->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($pedidos->pedidoActivo->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
?>
</select>
</span>
<?php echo $pedidos->pedidoActivo->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($pedidos->pedidoTratado->Visible) { // pedidoTratado ?>
	<tr id="r_pedidoTratado">
		<td><span id="elh_pedidos_pedidoTratado"><?php echo $pedidos->pedidoTratado->FldCaption() ?></span></td>
		<td<?php echo $pedidos->pedidoTratado->CellAttributes() ?>>
<span id="el_pedidos_pedidoTratado" class="control-group">
<select data-field="x_pedidoTratado" id="x_pedidoTratado" name="x_pedidoTratado"<?php echo $pedidos->pedidoTratado->EditAttributes() ?>>
<?php
if (is_array($pedidos->pedidoTratado->EditValue)) {
	$arwrk = $pedidos->pedidoTratado->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($pedidos->pedidoTratado->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
?>
</select>
</span>
<?php echo $pedidos->pedidoTratado->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($pedidos->pedidoFechaPlanificada->Visible) { // pedidoFechaPlanificada ?>
	<tr id="r_pedidoFechaPlanificada">
		<td><span id="elh_pedidos_pedidoFechaPlanificada"><?php echo $pedidos->pedidoFechaPlanificada->FldCaption() ?></span></td>
		<td<?php echo $pedidos->pedidoFechaPlanificada->CellAttributes() ?>>
<span id="el_pedidos_pedidoFechaPlanificada" class="control-group">
<input type="text" data-field="x_pedidoFechaPlanificada" name="x_pedidoFechaPlanificada" id="x_pedidoFechaPlanificada" placeholder="<?php echo $pedidos->pedidoFechaPlanificada->PlaceHolder ?>" value="<?php echo $pedidos->pedidoFechaPlanificada->EditValue ?>"<?php echo $pedidos->pedidoFechaPlanificada->EditAttributes() ?>>
</span>
<?php echo $pedidos->pedidoFechaPlanificada->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($pedidos->pedidoMotivo->Visible) { // pedidoMotivo ?>
	<tr id="r_pedidoMotivo">
		<td><span id="elh_pedidos_pedidoMotivo"><?php echo $pedidos->pedidoMotivo->FldCaption() ?></span></td>
		<td<?php echo $pedidos->pedidoMotivo->CellAttributes() ?>>
<span id="el_pedidos_pedidoMotivo" class="control-group">
<select data-field="x_pedidoMotivo" id="x_pedidoMotivo" name="x_pedidoMotivo"<?php echo $pedidos->pedidoMotivo->EditAttributes() ?>>
<?php
if (is_array($pedidos->pedidoMotivo->EditValue)) {
	$arwrk = $pedidos->pedidoMotivo->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($pedidos->pedidoMotivo->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
?>
</select>
<?php
$sSqlWrk = "SELECT `demoraId`, `demoraNombre` AS `DispFld`, '' AS `Disp2Fld`, '' AS `Disp3Fld`, '' AS `Disp4Fld` FROM `pedidomotivodemora`";
$sWhereWrk = "";

// Call Lookup selecting
$pedidos->Lookup_Selecting($pedidos->pedidoMotivo, $sWhereWrk);
if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
?>
<input type="hidden" name="s_x_pedidoMotivo" id="s_x_pedidoMotivo" value="s=<?php echo ew_Encrypt($sSqlWrk) ?>&amp;f0=<?php echo ew_Encrypt("`demoraId` = {filter_value}"); ?>&amp;t0=3">
</span>
<?php echo $pedidos->pedidoMotivo->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($pedidos->pedidoAnterior->Visible) { // pedidoAnterior ?>
	<tr id="r_pedidoAnterior">
		<td><span id="elh_pedidos_pedidoAnterior"><?php echo $pedidos->pedidoAnterior->FldCaption() ?></span></td>
		<td<?php echo $pedidos->pedidoAnterior->CellAttributes() ?>>
<span id="el_pedidos_pedidoAnterior" class="control-group">
<input type="text" data-field="x_pedidoAnterior" name="x_pedidoAnterior" id="x_pedidoAnterior" size="30" placeholder="<?php echo $pedidos->pedidoAnterior->PlaceHolder ?>" value="<?php echo $pedidos->pedidoAnterior->EditValue ?>"<?php echo $pedidos->pedidoAnterior->EditAttributes() ?>>
</span>
<?php echo $pedidos->pedidoAnterior->CustomMsg ?></td>
	</tr>
<?php } ?>
</table>
</td></tr></table>
<?php
	if (in_array("pedidodetalle", explode(",", $pedidos->getCurrentDetailTable())) && $pedidodetalle->DetailEdit) {
?>
<?php include_once "pedidodetallegrid.php" ?>
<?php } ?>
<?php
	if (in_array("pedidohistorial", explode(",", $pedidos->getCurrentDetailTable())) && $pedidohistorial->DetailEdit) {
?>
<?php include_once "pedidohistorialgrid.php" ?>
<?php } ?>
<button class="btn btn-primary ewButton" name="btnAction" id="btnAction" type="submit"><?php echo $Language->Phrase("EditBtn") ?></button>
</form>
<script type="text/javascript">
fpedidosedit.Init();
<?php if (EW_MOBILE_REFLOW && ew_IsMobile()) { ?>
ew_Reflow();
<?php } ?>
</script>
<?php
$pedidos_edit->ShowPageFooter();
if (EW_DEBUG_ENABLED)
	echo ew_DebugMsg();
?>
<script type="text/javascript">

// Write your table-specific startup script here
// document.write("page loaded");

</script>
<?php include_once "footer.php" ?>
<?php
$pedidos_edit->Page_Terminate();
?>
